<template>
  <div style="display:inherit">
    {{day}}
  </div>
</template>
<script>
export default {
  name: 'Countdown',
  data () {
    return {
      day: 0
    }
  },
  mounted () {
    this.getCountdown()
  },
  methods: {
    // 考试倒计时，每次刷新页面会重置
    getCountdown () {
      const end = Date.parse(new Date('2020-11-07'))
      const now = Date.parse(new Date())
      const msec = end - now
      let day = parseInt(msec / 1000 / 60 / 60 / 24)
      console.log(day)
      this.day = day
      // let that = this
      // setTimeout(function () {
      //   that.getCountdown()
      // }, 100000)
    }
  }
}
</script>
